package com.oscar.ehome.presenter;

import com.oscar.ehome.bean.teamBean.TeamListBean;
import com.oscar.ehome.bean.teamBean.UpdateBean;
import com.oscar.ehome.bean.teamBean.UserAppInfoBean;
import com.oscar.ehome.bean.teamBean.UserRoleStaticBean;
import com.oscar.ehome.bean.teamBean.UserStartStaticBean;
import com.oscar.ehome.model.HttpModel;
import com.oscar.ehome.model.HttpModelImple;
import com.oscar.ehome.model.OnHttpListener;
import com.oscar.ehome.view.setview.view.SetView;
import com.oscar.ehome.view.teamview.view.MessageInfoView;
import com.oscar.ehome.view.teamview.view.TeamListView;

/**
 * Created by 柒岇 on 2017/7/5.
 */

public class TeamPresenter extends BasePresenter {

    HttpModel httpModel;
    TeamListView teamListView;
    MessageInfoView messageInfoView;


    public TeamPresenter(TeamListView teamListView) {
        this.httpModel = new HttpModelImple();
        this.teamListView = teamListView;
    }

    public TeamPresenter(MessageInfoView messageInfoView) {
        this.httpModel = new HttpModelImple();
        this.messageInfoView = messageInfoView;
    }


    /**
     * 团队列表
     *
     * @param token
     * @param id
     * @param type
     */
    public void LoadUserTeamAppList(String token, String id, String type) {

        httpModel.LoadUserTeamAppList(token, id, type, new OnHttpListener<TeamListBean>() {
            @Override
            public void onSuccess(TeamListBean obj) {
                if (teamListView != null)
                    teamListView.LoadUserTeamAppList(obj);
            }

            @Override
            public void onError(String msg) {
                if (teamListView != null)
                    teamListView.erry(msg);
            }

            @Override
            public void onFailure() {
                if (teamListView != null)
                    teamListView.erroy();
            }
        });
    }

    /**
     * 职级统计
     *
     * @param token
     * @param id
     */
    public void LoadUserRoleStatisticsAppList(String token, String id) {
        httpModel.LoadUserRoleStatisticsAppList(token, id, new OnHttpListener<UserRoleStaticBean>() {
            @Override
            public void onSuccess(UserRoleStaticBean obj) {
                if (teamListView != null)
                    teamListView.LoadUserRoleStatisticsAppList(obj);
            }

            @Override
            public void onError(String msg) {
                if (teamListView != null)
                    teamListView.erry(msg);
            }

            @Override
            public void onFailure() {
                if (teamListView != null)
                    teamListView.erroy();
            }
        });

    }

    /**
     * 星级统计
     *
     * @param token
     * @param id
     */
    public void LoadUserStartStatisticsAppList(String token, String id) {
        httpModel.LoadUserStartStatisticsAppList(token, id, new OnHttpListener<UserStartStaticBean>() {
            @Override
            public void onSuccess(UserStartStaticBean obj) {
                if (teamListView != null)
                    teamListView.LoadUserStartStatisticsAppList(obj);
            }

            @Override
            public void onError(String msg) {
                if (teamListView != null)
                    teamListView.erry(msg);
            }

            @Override
            public void onFailure() {
                if (teamListView != null)
                    teamListView.erroy();
            }
        });

    }

    /**
     * 个人信息
     *
     * @param token
     * @param id
     */
    public void LoadUserAppInfo(String token, String id) {
        httpModel.LoadUserAppInfo(token, id, new OnHttpListener<UserAppInfoBean>() {
            @Override
            public void onSuccess(UserAppInfoBean obj) {
                if (teamListView != null)
                    teamListView.LoadUserAppInfo(obj);
            }

            @Override
            public void onError(String msg) {
                if (teamListView != null)
                    teamListView.erry(msg);
            }

            @Override
            public void onFailure() {
                if (teamListView != null)
                    teamListView.erroy();
            }
        });
    }

    /**
     * 获取职级下人员
     *
     * @param token
     * @param id
     */
    public void getReoalList(String token, String id, String roleMobileId) {
        httpModel.getRoaleList(token, id, roleMobileId, new OnHttpListener<TeamListBean>() {
            @Override
            public void onSuccess(TeamListBean obj) {
                if (teamListView != null)
                    teamListView.getRoalList(obj);
            }

            @Override
            public void onError(String msg) {
                if (teamListView != null)
                    teamListView.erry(msg);
            }

            @Override
            public void onFailure() {
                if (teamListView != null)
                    teamListView.erroy();
            }
        });
    }

    /**
     * 获取星级下人员
     *
     * @param token
     * @param id
     */
    public void getStartList(String token, String id, String starLevel) {
        httpModel.getStartLeveList(token, id, starLevel, new OnHttpListener<TeamListBean>() {
            @Override
            public void onSuccess(TeamListBean obj) {
                if (teamListView != null)
                    teamListView.getStartLeves(obj);
            }

            @Override
            public void onError(String msg) {
                if (teamListView != null)
                    teamListView.erry(msg);
            }

            @Override
            public void onFailure() {
                if (teamListView != null)
                    teamListView.erroy();
            }
        });
    }

    /**
     * 上传图片
     *
     * @param token
     */
    public void upLoadImage(String token, String photo) {
        httpModel.upLoadImage(token, photo, new OnHttpListener<String>() {
            @Override
            public void onSuccess(String obj) {
                if (messageInfoView != null)
                    messageInfoView.checkUpImage(obj);
            }

            @Override
            public void onError(String msg) {
                if (messageInfoView != null)
                    messageInfoView.erry(msg);
            }

            @Override
            public void onFailure() {
                if (messageInfoView != null)
                    messageInfoView.erroy();
            }
        });
    }


}
